package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;

import java.io.*;

/**
 * 描述：存储和回复数据
 */
public class StoringAndRecoveringData {
    public static void main(String[] args) {
        try (DataOutputStream out = new DataOutputStream(
                new BufferedOutputStream(
                        new FileOutputStream("E:\\L.info\\L.Application\\L.Tester\\src\\main\\java\\com\\le\\tester\\java8\\doc\\Data.txt")
                )
        )) {
            out.writeDouble(3.1415926);
            out.writeUTF("\nThat was pi\n");
            out.writeDouble(1.41413);
            out.writeUTF("\nSquare root of 2");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        try (DataInputStream in = new DataInputStream(new BufferedInputStream(
                new FileInputStream("E:\\L.info\\L.Application\\L.Tester\\src\\main\\java\\com\\le\\tester\\java8\\doc\\Data.txt")))) {

            System.out.println(in.readDouble());
            System.out.println(in.readUTF());
            System.out.println(in.readDouble());
            System.out.println(in.readUTF());

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
